package com.ruoyi.question.service.impl;

import com.ruoyi.common.domain.question.Subject;
import com.ruoyi.common.domain.video.VideoRecord;
import com.ruoyi.question.dao.mapper.SubjectMapper;
import com.ruoyi.question.service.ISubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SubjectServiceImpl implements ISubjectService {

    @Autowired
    private SubjectMapper dao;


    @Override
    public List<Subject> selectList(Subject record) {
        return dao.selectList(record);
    }

    @Override
    public int updateRecord(Subject record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int saveRecord(Subject record) {
        if(record.getId() != null) {
            return dao.updateByPrimaryKeySelective(record);
        }
        return dao.insertSelective(record);
    }

    @Override
    public int delete(Subject record) {
        return dao.deleteByPrimaryKey(record.getId());
    }

    @Override
    public Subject findById(Long id) {
        Subject record = dao.selectByPrimaryKey(id);
        if(record == null) {
            return null;
        }
        return record;
    }

    @Override
    public Subject selectByPrimaryKey(Long id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public Integer levelBySubjectId(Integer subjectId) {
        return dao.selectByPrimaryKey(subjectId).getLevel();
    }
}
